package com.lifang.test5;

import com.lifang.framework.annotation.beans.Component;
import com.lifang.framework.annotation.beans.PostConstruct;
import com.lifang.framework.annotation.beans.PreDestroy;
import com.lifang.framework.beans.BeansException;
import com.lifang.framework.beans.factory.BeanFactory;
import com.lifang.framework.beans.factory.BeanFactoryAware;
import com.lifang.framework.beans.factory.BeanNameAware;
import com.lifang.framework.beans.factory.DisposableBean;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

@Slf4j
@Component
public class UserServiceImplB implements UserService, BeanNameAware, BeanFactoryAware, DisposableBean {

    @Resource(name = "userServiceImplA")
    private UserService userServiceA;

    @Override
    public void sayHello(String name) {
        log.info("你好啊" + name);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        log.info("感知到BeanFactory " + beanFactory);
    }

    @Override
    public void setBeanName(String name) {
        log.info("感知到BeanName " + name);
    }

    @Override
    public void destroy() throws Exception {
        log.info("我被销毁了destroy");
    }

    @PostConstruct
    public void init() {
        log.info("init 我初始化完成了");
    }

    @PreDestroy
    public void preDestroy() {
        log.info("我被销毁了preDestroy");
    }

}
